package com.nstc.sftpExchange.controller;

import com.nstc.sftpExchange.common.RestResponse;
import com.nstc.sftpExchange.constants.Constants;
import com.nstc.sftpExchange.entity.scope.UploadScope;
import com.nstc.sftpExchange.service.RequestSftpExchangeService;
import com.nstc.sftpExchange.service.SftpFileHandleService;
import com.nstc.sftpExchange.service.SftpService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/upload")

public class UploadController {

    @Resource
    private SftpFileHandleService sftpFileHandleService;

    @Resource
    private RequestSftpExchangeService requestSftpExchangeService;

    @PostMapping("/frontMachine")
    public RestResponse<String> frontMachineUpload(@RequestBody UploadScope uploadScope) {
        return sftpFileHandleService.handleFile(Constants.SFTP_NAME_N9, Constants.SFTP_NAME_FINANCE, uploadScope);
    }

    @PostMapping("/forward")
    public RestResponse<String> backMachineUpload(@RequestBody UploadScope uploadScope) {
        return requestSftpExchangeService.requestSftpExchange(uploadScope);
    }
}
